﻿using System.Collections.Generic;
using Sedge.Core.Configuration.Property;
using Sedge.Core.Execution.ReportElements;

namespace Sedge.Core.Configuration.Report
{
	class TableSource : IDataSource
	{
		private Suite _suite;

		public Options Options { get; set; }
		public string Caption { get; set; }

		public void PrepareSource(Suite suite)
		{
			_suite = suite;
		}

		public List<IReportElement> GetReportElements()
		{
			if (Options == null)
				return new List<IReportElement>();

			ReportTable table = new ReportTable(_suite) { Header = Caption };
			foreach (KeyValuePair<string, string> pair in Options.OptionsDictionary)
			{
				table.AddRow(PropertyResolver.ResolveValue(_suite, pair.Key), pair.Value);
			}

			return new List<IReportElement> { table };
		}
	}
}
